%{
#include <stdlib.h>
#include <stdio.h>
#include "colors.tab.h"
%}

%option yylineno
%x comment string defzero

%%

   /* Handle comments */
"/*"         BEGIN(comment);
<comment>[^*\n]*        /* eat anything that's not a '*' */
<comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
<comment>\n             /*++yylineno;*/
<comment>"*"+"/"        BEGIN(INITIAL);

#if[ ]*0  			BEGIN(defzero);
<defzero>#endif 	BEGIN(INITIAL);
<defzero>[^#] 		/* */

#define { return DEFINE; }

CLR_[A-Z_]+    {yylval.s = strdup(yytext+4); return COLOR;}
NO_COLOR       {yylval.s = strdup(yytext); return COLOR;}
BRIGHT		   {yylval.s = strdup(yytext); return COLOR;}
HI_[A-Z_]+     {yylval.s = strdup(yytext+3); return XCOLOR;}
DRAGON_[A-Z_]+ {yylval.s = strdup(yytext); return XCOLOR;}
[0-9]+         {yylval.i = atoi(yytext); return INT;}
[A-Z_]+
[ \t]+  /* eat */
\n      /* eat */
^[^#]       /* eat */
#ifndef[^\n]+  { return IFNDEF; }
#endif[^\n]*   { return ENDIF; }
<<EOF>> {return THE_END;}
%%

int yywrap() {
 return 1;
}
